<link href="<@sp.static/>/assets/plugins/bootstrap/css/bootstrap.min.css?v=1.8.6" rel="stylesheet"/>
<link href="<@sp.static/>/assets/css/style.min.css?v=1.8.6" rel="stylesheet"/>
<link href="<@sp.static/>/css/style.css?v=1.8.6" rel="stylesheet"/>
<link href="<@sp.static/>/assets/plugins/datatables/css/data-table.css?v=1.8.6" rel="stylesheet"/>
<div class="iframe-base">
    <div class="iframe-panel" data-sortable-id="form-stuff-5">
        <div class="panel-body">
            <form class="form-horizontal do-confirm-form" id="confirmForm" name="confirmForm" action="" method="post">
                <input type="hidden" id="userId" name="userId" value="${userInfo.id}">
                <div class="form-group m-l-10">
                    <label class="col-md-2 control-label">会员信息</label>
                    <div class="col-md-8 c-info">
                        <span class="form-control info">${userInfo.name} <#if userInfo.mobile> ${userInfo.mobile[0..2]}*****${userInfo.mobile[userInfo.mobile?length-4..userInfo.mobile?length-1]}</#if>
                        <#if userInfo.status == 'A'><span style="display: inline" class="status-active">正常</span><#else><span style="display: inline" class="status-disabled">禁用</span></#if></span>
                    </div>
                </div>
                <div class="form-group m-l-10">
                    <label class="col-md-2 control-label">可用余额</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control remark" id="balance" disabled name="balance" placeholder="可用余额" value="${userInfo.balance}元">
                    </div>
                </div>
                <div class="form-group m-l-10">
                    <label class="col-md-2 control-label">变更方式</label>
                    <div class="col-md-8">
                        <div class="type-option">
                            <label class="item"><input type="radio" name="type" id="type1" value="1" checked>增加</label>
                            <label class="item"><input type="radio" name="type" id="type2" value="2">减少</label>
                        </div>
                    </div>
                </div>
                <div class="form-group m-l-10">
                    <label class="col-md-2 control-label"><span style="color:red;">*</span>变更金额</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control remark" id="amount" name="amount" placeholder="变更金额，单位：元" value="">
                    </div>
                </div>
                <div class="form-group m-l-10">
                    <label class="col-md-2 control-label">备注信息</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control remark" id="remark" name="remark" placeholder="备注信息" value="">
                    </div>
                </div>
                <div class="form-group m-l-10">
                    <label class="col-md-2 control-label"></label>
                    <div class="col-md-10">
                         <button type="button" id="submitButton" class="btn btn-sm btn-danger">确认</button>
                         <button type="button" id="submitCancel" class="btn btn-sm btn-success">取消</button>
                    </div>
                </div>
            </form>
     </div>
    </div>
</div>
<script src="<@sp.static/>/js/jquery/jquery-3.0.0.min.js?v=1.8.6" type="text/javascript" charset="UTF-8"></script>
<script src="<@sp.static/>/js/jquery/validation/jquery.validate.min.js?v=1.8.6" type="text/javascript" charset="UTF-8"></script>
<script src="<@sp.static/>/assets/plugins/jquery-ui/ui/minified/jquery-ui.min.js?v=1.8.6"></script>
<script src="<@sp.static/>/assets/plugins/bootstrap/js/bootstrap.min.js?v=1.8.6"></script>
<script src="<@sp.static/>/js/layer/layer.js?v=1.8.6" type="text/javascript" charset="UTF-8"></script>
<script src="<@sp.static/>/js/custom/util.js?v=1.8.6" type="text/javascript" charset="UTF-8"></script>
<script src="<@sp.static/>/js/custom/message.js?v=1.8.6" type="text/javascript" charset="UTF-8"></script>
<script src="<@sp.static/>/js/custom/send.js?v=1.8.6" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript" language="JavaScript">
    $(function () {
        $('#submitButton').click(function() {
            let amount = $("#amount").val();
            if (amount.length < 1) {
                layer.alert("请先输入变更金额！");
                return false;
            }

            if (amount <= 0) {
                layer.alert("变更金额格式有误！");
                return false;
            }

            layer.confirm('您确定提交余额变更吗？', {
                btn: ['确定', '取消']
            }, function () {
                $.ajax({
                    type: "POST",
                    data:{"userId": $("#userId").val(), "amount": $("#amount").val(), "type": $("input[name='type']:checked").val(), "remark": $("#remark").val()},
                    url: "${rc.contextPath}/backend/balance/doRecharge",
                    success: function (data) {
                        if (data.result) {
                            layer.alert("恭喜，余额变更成功！");
                            $('#amount').val("");
                            $('#remark').val("");
                            $('#balance').val(data.data.userInfo.balance + '元');
                            parent.$("#doSearch").click();
                            $('#submitCancel').click()
                            return;
                        } else {
                            layer.alert(data.msg);
                            return;
                        }
                    }
                })
                $.close();
            }, function () {
                $.close();
            });
        });
        $('#submitCancel').click(function() {
            let index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        })
    })
</script>